﻿var detectBrowser = function (a) {
    if (navigator.userAgent.toLowerCase().indexOf(a) > -1) {
        return true
    } else {
        return false
    }
};
var width = parseInt(window.screen.width);
if (detectBrowser("mz-m2")) {
    width = 360
}
var scale = width / 640;
var userScalable = "no";
if (detectBrowser("qq/")) {
    userScalable = "no"
}
$("#viewport").attr("content", "width=640,user-scalable=" + userScalable + ",initial-scale=" + scale);

function cancel(a) {
    $(a).parent().css("display", "none");
    $(".zhegai").css("display", "none")
}

function scrollTable2() {
    var c = 1;
    var a = $(".sharesList tr").length;
    $(".sharesList").append($(".sharesList tr").clone());
    var b = $(".sharesList").eq(0);
    setInterval(function () {
        b.css("marginTop", -94 * c);
        c++;
        if (c == a + 1) {
            setTimeout(function () {
                b.css("transition", "none");
                b.css("marginTop", -6);
                c = 1;
                setTimeout(function () {
                    b.css("transition", "all .7s")
                }, 700)
            }, 1000)
        }
    }, 2500)
}

function GetQueryString(a) {
    var b = new RegExp("(^|&)" + a + "=([^&]*)(&|$)");
    var c = window.location.search.substr(1).match(b);
    if (c != null) {
        return unescape(c[2])
    }
    return null
}

cNum = GetQueryString("gp") ? GetQueryString("gp") : "";
if (cNum != "") {
    // getCodeInfo(cNum)
}

function getCodeInfo(a, b) {
    gdt("track", "CONSULT", {"key1": "value1", "key2": "value2"});
    $.ajax({
        url: "http://qd.10jqka.com.cn/quote.php?cate=real&type=stock&return=json&callback=showStockData&code=" + a,
        type: "get",
        dataType: "jsonp",
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        timeout: 3000
    }).done(function (c) {
        try {
            $(".gName,.btnBg span,.btnBgb span,.gpName,.tomorrow .red,.dialogBg span").html(c.info[a].name);
            $(".gCode").text("( " + a + " )");
            $(".xianjia").text(c.data[a]["10"]);
            $(".zhangdie").text(c.data[a]["264648"].slice(0, -1));
            $(".zhangfu").text(c.data[a]["199112"].slice(0, -1) + "%");
            $(".jinkai").text(c.data[a]["7"]);
            $(".zuigao").text(c.data[a]["8"]);
            $(".zuidi").text(c.data[a]["9"]);
            $(".zuoshou").text(c.data[a]["6"]);
            $(".chengjiaoliang").text((c.data[a]["13"] / 10000).toFixed(2) + "万");
            $(".chengjiaoe").text((c.data[a]["19"] / 100000000).toFixed(2) + "亿");
            $(".zhenfu").text((c.data[a]["526792"] / 1).toFixed(2) + "%");
            $(".huanshou").text((c.data[a]["1968584"] / 1).toFixed(2) + "%");
            if (c.data[a]["199112"] >= 0) {
                $(".zhangdie,.zhangfu,.xianjia").css("color", "#ee3a23");
                $(".zhishu img").attr("src", "files/arrow.png")
            } else {
                $(".zhangdie,.zhangfu,.xianjia").css("color", "#03a20c");
                $(".zhishu img").attr("src", "files/arrowdown.png")
            }
            if (!c.data[a]["10"]) {
                $(".xianjia").text("停牌");
                $(".zhangfu").text("");
                $(".zhishu img").css("opacity", 0).css("visibility", "hidden")
            } else {
                $(".zhishu img").css("opacity", 1).css("visibility", "visible")
            }
        } catch (d) {
        }
        b()
    }).fail(function () {
        b()
    })
}

base();

function replaceX(a) {
    re = /([\s\S]{3})([\s\S]{3})/;
    return a.replace(re, "$1***")
}

function replaceY(a) {
    return a.replace(/.(?=.)/g, "**")
}

function base() {
}

function showLocale(f) {
    var h, a, d;
    var g = f.getYear();
    if (g < 1900) {
        g = g + 1900
    }
    var i = f.getMonth() + 1;
    if (i < 10) {
        i = "0" + i
    }
    var j = f.getDate();
    if (j < 10) {
        j = "0" + j
    }
    var b = f.getHours();
    if (b < 10) {
        b = "0" + b
    }
    var c = f.getMinutes();
    if (c < 10) {
        c = "0" + c
    }
    var k = f.getSeconds();
    if (k < 10) {
        k = "0" + k
    }
    var e = f.getDay();
    if (e == 0) {
        a = "<font>"
    }
    if (e > 0 && e < 7) {
        a = "<font >"
    }
    h = a + g + "/" + i + "/" + j + " &nbsp&nbsp" + b + ":" + c + ":" + k + " ";
    return (h)
}

function tick() {
    var a;
    a = new Date();
    document.getElementById("new_data").innerHTML = showLocale(a);
    window.setTimeout("tick()", 1000)
}

tick();

function animate() {
    $(".tan_content").show();
    $(".dialog").hide();
    $("html, body").animate({scrollTop: 0}, 100);
    $(".charts").animate({width: "25%"}, 500, "", function () {
        $(".discuss").html("正在通过最小二乘法OLS确定必要报 酬率...")
    });
    $(".charts").animate({width: "50%"}, 600, "", function () {
        $(".discuss").html("正在通过VAR系统确认风险值...")
    });
    $(".charts").animate({width: "75%"}, 700, "", function () {
        $(".discuss").html("正在通过量价交易模型...")
    });
    $(".charts").animate({width: "100%"}, 800, "", function () {
        $(".discuss").html("正在通过量价交易模型...");
        $(".charts").css("width", "0");
        $(".tan_content").hide();
        $(".dialog").show();
        $(".phonec").focus()
    })
}

function sendtxb() {
    $(".tan_content").show();
    $(".dialog").hide();
    $("html, body").animate({scrollTop: 0}, 100);
    $(".charts").animate({width: "0%"}, 1, "", function () {
        $(".discuss").html("正在发往投研部...")
    });
    $(".charts").animate({width: "25%"}, 500, "", function () {
        $(".discuss").html("投研部接收中...")
    });
    $(".charts").animate({width: "50%"}, 500, "", function () {
        $(".discuss").html("投研部接收中...")
    });
    $(".charts").animate({width: "98%"}, 1200, "", function () {
        $(".discuss").html("投研部接收中...")
    })
}

function sendcomplete() {
    $(".charts").clearQueue().animate({width: "100%"}, 50, "", function () {
        $(".discuss").html("投研部接收中...");
        $(".charts").css("width", "0");
        $(".tan_content").hide();
        $(".dialog").show();
        $(".phonec").focus()
    })
}

function checkData(f, g, e) {
    var d = new RegExp("^\d{6}$");
    var a = false;
    for (var c = 0; c < f.length; c++) {
        var b = f[c];
        if (b[g] == e) {
            a = true;
            break
        }
    }
    return a
}

$(".circle").on("click", function () {
    $(".tan_div").hide()
});
$("#sm1,.btnBg").on("click", function () {
    cNum = stocks.getInputVal();
    if (cNum == "") {
        layer.msg("请输入正确的股票代码");
        return false
    } else {
        if (stocks.isExist()) {
            cNum = stocks.get().c
        }
        getCodeInfo(cNum, function () {
            if ($(".gName").text() === "") {
                layer.msg("请选择正确的股票");
                return false
            }
            setTimeout(function () {
                $(".tan_div").height($("body").height());
                $(".discuss").html("正在通过事件驱动策略模型...");
                animate();
                $(".tan_div").show()
            }, 500)
        })
    }
});

function saveMobile() {
    zpcj = cNum;
    if (zpcj == "") {
        layer.msg("请输入正确的股票代码");
        return false
    } else {
        $(".discuss").html("正在通过事件驱动策略模型...");
        animate();
        $(".tan_div").height($("body").height());
        $(".tan_div").show()
    }
};